
// This file contains common jQuery snippets, feel free to add stuff




// Search box that grabs the value of your text input and shows it, then hides on focus

		var $search = $('#search-text-input');//Cache the element for faster DOM searching since we are using it more than once
		original_val = $search.val(); //Get the original value to test against. We use .val() to grab value="Search"
		$search.focus(function(){ //When the user tabs/clicks the search box.
			if($(this).val()===original_val){ //If the value is still the default, in this case, "Search"
				$(this).val('');//If it is, set it to blank
			}
		})
		.blur(function(){//When the user tabs/clicks out of the input
			if($(this).val()===''){//If the value is blank (such as the user clicking in it and clicking out)...
				$(this).val(original_val); //... set back to the original value
			}
		});


// Target a elements with rel="external" and open them in a new window

		$("li.box").click(function(){
		  window.location=$(this).find("a").attr("href"); return false;
		});
		
// Target a elements with rel="external" and open them in a new window

		$("a[@rel~='external']").click( function() {
		    window.open( $(this).attr('href') );
		    return false;
		});

// Target a elements that link to .pdf's and open them in a new window

		$("a[href*=.pdf]").click(function(){
		    window.open(this.href);
		    return false;
		});

// Target specific browsers with jQuery

		//A. Target Safari
		if( $.browser.safari ) $("#menu li a").css("padding", "1em 1.2em" );
		
		//B. Target anything above IE6
		if ($.browser.msie && $.browser.version > 6 ) $("#menu li a").css("padding", "1em 1.8em" );
		
		//C. Target IE6 and below
		if ($.browser.msie && $.browser.version <= 6 ) $("#menu li a").css("padding", "1em 1.8em" );
		
		//D. Target Firefox 2 and above
		if ($.browser.mozilla && $.browser.version >= "1.8" ) $("#menu li a").css("padding", "1em 1.8em" );


// Load XML, then find every Tutorial and print the author to #output

		$(document).ready(function()
		{
		  $.ajax({
		    type: "GET",
		    url: "jquery_xml.xml",
		    dataType: "xml",
		    success: parseXml
		  });
		});
		
		function  parseXml(xml){
		  //find every Tutorial and print the author
		  $(xml).find("Tutorial").each(function()
		  {
		    $("#output").append($(this).attr("author") + "<br />");
		  });
		
		}


// Look for the media-type you wish to switch then set the href to your new style sheet  
		$('link[media='screen']').attr('href', 'Alternative.css');



// Preload images
		
		(function($) {
		  var cache = [];
		  // Arguments are image paths relative to the current page.
		  $.preLoadImages = function() {
		    var args_len = arguments.length;
		    for (var i = args_len; i--;) {
		      var cacheImage = document.createElement('img');
		      cacheImage.src = arguments[i];
		      cache.push(cacheImage);
		    }
		  }
		})(jQuery)
		
		
		jQuery.preLoadImages("image1.gif", "/path/to/image2.png");



// Log jQuery events in Firebug
// Usage: $('#someDiv').hide().log('div hidden').addClass('someClass');
	jQuery.log = jQuery.fn.log = function (msg) {
	      if (console){
	         console.log("%s: %o", msg, this);
	      }
	      return this;
	};
	
	
$(document).ready(function () {
  $("#slika1").fadeTo(0,0);

  $("#test,#submenu2").hover(
    function () {
      $("#slika1").stop(true).fadeTo("normal",1);
    }, 
    function () {
      $("#slika1").fadeTo("normal",0);
    }
  );       
});
